/*
 * Aboboo Android
 * Copyright (C) 2012 www.aboboo.com
 * 
 */

package com.aboboo.android.player;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;

/**
 * 
 * @author fangpeng
 * 
 * @version 1.0 2013-01-31
 * 
 */
public class PhoneStateReceiver extends BroadcastReceiver {
	@Override
	public void onReceive(Context context, Intent intent) {
		// if android.os.Build.VERSION.SDK_INT >= 8 we use audio focus.
		if (android.os.Build.VERSION.SDK_INT < 8) {
			TelephonyManager tm = (TelephonyManager) context
					.getSystemService(Context.TELEPHONY_SERVICE);
			if (tm.getCallState() != TelephonyManager.CALL_STATE_IDLE) {
				context.startService(new Intent(MediaPlayerService.ACTION_PAUSE));
			}
		}
	}
}
